# 画出两个种群数量的月度观测数据

import matplotlib.pyplot as plt

# 观测数据 (x, y, t)
data = [
(60,30, 0), 
(63,34, 1), 
(64,38, 2), 
(63,44, 3), 
(61,50, 4), 
(58,55, 5), 
(53,58, 6), 
(44,56, 8), 
(39,47, 10), 
(38,38, 12), 
(41,30, 14), 
(46,27, 16), 
(53,26, 18), 
]

# 提取 x, y, t
x_vals = [point[0] for point in data]
y_vals = [point[1] for point in data]
t_vals = [point[2] for point in data]

# 创建图形
plt.figure(figsize=(8, 6))

# 绘制散点（所有观测点）
plt.plot(x_vals, y_vals, 'bo-', label='Trajectory (time-ordered)', linewidth=2, markersize=6)

# 可选：标注时间顺序
for i in range(len(data)):
    plt.text(x_vals[i], y_vals[i], str(t_vals[i]), fontsize=14, color='red', alpha=0.8)

# 设置标签和标题
plt.xlabel('Prey Population (x)')
plt.ylabel('Predator Population (y)')
plt.title('Phase Plot: Predator vs Prey (Monthly Observations, Connected by Time)')
plt.grid(True, alpha=0.3)
plt.legend()

# 显示图形
plt.axis('equal')  # 可选：使坐标轴比例一致
plt.tight_layout()

